package client_package;

import java.io.IOException;

import client_package.Controleur.StatutSound;


public class ThreadListenerInfos implements Runnable {
	private Controleur c;
	
	private VueSalon salon;
	
	public ThreadListenerInfos(Controleur c) {
		this.c = c;
		salon = null;
	}

	public void run() {
		c.setStatutSound(StatutSound.Pas_En_Communication);
		//System.out.println("J'ouvre threadListenerInfos\n");
		String ch = "";
		this.salon = ((VueSalon)c.getVue());
		try {
			ch = c.getIn().readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		while(!ch.equals("%Server% FinEnvoisInfos")) {
			try {
				if(ch.equals("%Server% DebEnvoisInfos")) {
					salon.raz();
					ch = c.getIn().readLine();
				}
				salon.alimente(ch, c.getIn().readLine(), c.getIn().readLine(), c.getIn().readLine(), c.getIn().readLine(), c.getIn().readLine());
				ch = c.getIn().readLine();
				/*if(ch == null) {
					break;
				}*/
				Thread.sleep(1);
			} catch (IOException e) {
				e.printStackTrace();
			} catch (InterruptedException e) {
				Thread.currentThread().interrupt();
				break;
			}
		}
		//System.out.println("Je sors de threadListenerInfos\n");
	}
}